package Sort.面试;

import org.junit.Test;

public class DPSort {

    public static int getNumOfMethod(int x, int y){
        int dp[][] = new int[x+1][y+1];
        for(int i = 1; i <= x; i++){
            dp[i][0] = 1;
        }
        for(int j = 1; j <= y; j++){
            dp[0][j] = 1;
        }

        dp[0][1] = 1;
        for(int i = 1; i <= x; i++){
            for(int j = 1; j<= y; j++){
                dp[i][j] = dp[i-1][j] + dp[i][j-1];
            }
        }

        return dp[x][y];
    }

    @Test
    public void test(){
        System.out.println(getNumOfMethod(5,8));
        System.out.println(countOfMethod(5,8));
    }


    public static int countOfMethod(int x, int y){
        int[][] dp = new int[x+1][y+1];
        for(int i = 0; i <= x; i ++){
            dp[i][0] =  1;
        }
        for (int j = 0; j <= y; j ++){
            dp[0][j] = 1;
        }

        for(int i = 1; i <= x; i ++){
            for(int j = 1; j <= y; j++){
                dp[i][j] = dp[i][j-1] + dp[i-1][j];
            }
        }
        return dp[x][y];
    }
    
}
